package org.jeecg.demo.wx.event;

import org.jeecg.demo.wx.enumeration.ScheduleStatusEnum;
import org.jeecg.demo.wx.util.UpdateCountUtil;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 功能描述
 *
 * @author: zgq
 * @date: 2024年03月10日 13:49
 */
@Component
public class UnReadEventListener implements ApplicationListener<UnReadEvent> {

    @Autowired
    private UpdateCountUtil updateCountUtil;

    @Override
    @Async
    public void onApplicationEvent(@NotNull UnReadEvent event) {
        Set<String> userIds = event.getUserIds();
        for (String userId : userIds) {
            updateCountUtil.plus(userId, null,ScheduleStatusEnum.UNREAD);
        }
    }
}

